home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 836 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  56 lines

  1. Newsgroups: comp.lang.c++
  2. Path: leeds.ac.uk!news
  3. From: Philw@psychology.leeds.ac.uk (Phil Worsley)
  4. Subject: VC++ 1.5 Newbie Question (Specialist problem)
  5. Message-ID: <1996Jan7.165443.15962@leeds.ac.uk>
  6. NNTP-Posting-Host: psc_pc047.leeds.ac.uk
  7. Organization: Department of Psychology
  8. Date: Sun, 7 Jan 1996 16:54:43 +0000 (GMT)
  9. X-Newsreader: News Xpress Version 1.0 Beta #3
  10.  
  11. Hope someone here can help.
  12.  
  13. In VC++ 1.5, I'm trying to get some machine specific information for copy 
  14. protection reasons. Nothing flash, just getting the volume serial number. 
  15. But the _bios_disk functions don't work under Windows.
  16.  
  17. So I'm trying to get _dosintx and function 69, to run, this should give 
  18. access to the serial number. However it keeps GPF'ing on me. I'm not a VC++ 
  19. programmer by trade (I'm a lowly Novell sysop), I'm just trying to finish this 
  20. program for a friend. (the original programmer had a nervous breakdown)
  21.  
  22. The code I'm trying to use is this....
  23.  
  24. #include <dos.h>
  25. #include <stdafx.h>
  26. #include <malloc.h>
  27.  
  28. char __far *buffer;
  29.  
  30. CString SerialNumber::generateSerialNumber()
  31. {
  32.     union _REGS inregs, outregs;
  33.     struct _SREGS segregs;
  34.  
  35.     buffer=(char __far *) _fmalloc(512);    
  36.     inregs.h.ah = 0x69 // fn 69:
  37.     inregs.h.al = 0x00 // get serial number
  38.     inregs.h.bl = 0x80 // Hard disk C:
  39.     inregs.x.dx = _FP_OFF( buffer );
  40.     segregs.ds = _FP_SEG( buffer );
  41.     _intdosx( &inregs, &outregs, &segregs );
  42.      
  43.     CString serialno=CString(buffer);
  44.         
  45.     return serialno;
  46. }
  47.  
  48. It compiles but GPF's immediately when I execute it, is there something that I 
  49. haven't done? Or something I need to change in the Project Options?
  50.  
  51. Is there something else I could use to give me the serial number?
  52.  
  53. Please help someone.
  54.  
  55. P.
  56.